package cn.zzuisa.bluebox.biz.device.controller;

import cn.zzuisa.bluebox.base.facade.R;
import cn.zzuisa.bluebox.biz.device.entity.Device;
import cn.zzuisa.bluebox.biz.device.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @author Ao
 * @date 2020-01-22 02:17
 */
@RestController
@Api(tags = "User")
@RequestMapping("/user")
public class UserController {

    @PostMapping(value = "/login")
    @ResponseBody
    @ApiOperation(value = "Mock the user login")
    public R login(@RequestBody User user){
        System.out.println(user.getUsername());
        user.setAvatar("https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        user.setIntroduction("I am a super administrator");
        user.setRoles("admin");
        user.setToken("admin-token");
        return R.ok(user);
    }

    @GetMapping(value = "/info")
    @ResponseBody
    @ApiOperation(value = "Mock to get the userinfo")
    public R login(){
        User user = new User();
        user.setUsername("admin");
        user.setAvatar("https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        user.setIntroduction("I am a super administrator");
        user.setRoles("admin");
        user.setToken("admin-token");
        return R.ok(user);
    }
}
